//
//  LYQUserInfoManager.m
//  ZCProject
//
//  Created by Zheng on 2016/12/21.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQUserInfoManager.h"

@implementation LYQUserInfoManager

+ (instancetype)defaultManager {
    static LYQUserInfoManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[LYQUserInfoManager alloc] init];
    });
    return manager;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        _userInfoCache = [[YYCache alloc] initWithName:@"userInfo"];
    }
    return self;
}

- (void)updateUserInfo:(NSDictionary *)userInfo {
    [self.userInfoCache setObject:userInfo forKey:@"info"];
}

- (LYQUserInfoModel *)model {
    NSDictionary *userInfo = (NSDictionary *)[_userInfoCache objectForKey:@"info"];
    _model = [[LYQUserInfoModel alloc] initWithDic:userInfo];
    return _model;
}

- (NSString *)phoneNumber {
    return self.model.phoneNumber;
}

- (NSString *)password {
    return self.model.password;
}

@end
